home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 8 / The Arsenal Files Collection #8 (Arsenal Computer) (1996).ISO / g_quake / campki~1.zip / ITEMS.QC < prev    next >
Text File  |  1996-10-05  |  30KB  |  1,412 lines

  1. //items.qc for item-randomizer
  2.  
  3. void() W_SetCurrentAmmo;
  4. /* ALL LIGHTS SHOULD BE 0 1 0 IN COLOR ALL OTHER ITEMS SHOULD
  5. BE .8 .3 .4 IN COLOR */
  6.  
  7.  
  8. float(entity e) CheckEntity =
  9. {
  10.     if (e.classname == "weapon_nailgun")
  11.         return TRUE;
  12.     else if (e.classname == "weapon_supernailgun")
  13.         return TRUE;
  14.     else if (e.classname == "weapon_supershotgun")
  15.         return TRUE;
  16.     else if (e.classname == "weapon_rocketlauncher")
  17.         return TRUE;
  18.     else if (e.classname == "weapon_grenadelauncher")
  19.         return TRUE;
  20.     else if (e.classname == "weapon_lightning")
  21.         return TRUE;
  22.     else if (e.classname == "item_cells")
  23.         return TRUE;
  24.     else if (e.classname == "item_spikes")
  25.         return TRUE;
  26.     else if (e.classname == "item_shells")
  27.         return TRUE;
  28.     else if (e.classname == "item_rockets")
  29.         return TRUE;
  30.     else if (e.classname == "item_health")
  31.         return TRUE;
  32.     else if (e.classname == "item_artifact_invulnerability")
  33.         return TRUE;
  34.     else if (e.classname == "item_artifact_invisibility")
  35.         return TRUE;
  36.     else if (e.classname == "item_artifact_envirosuit")
  37.         return TRUE;
  38.     else if (e.classname == "item_artifact_super_damage")
  39.         return TRUE;
  40.     else if (e.classname == "item_armor1")
  41.         return TRUE;
  42.     else if (e.classname == "item_armor2")
  43.         return TRUE;
  44.     else if (e.classname == "item_armor3")
  45.         return TRUE;
  46.     return FALSE;
  47. };
  48.  
  49. void() SUB_regen =
  50. {
  51.  
  52.     local vector vTemp;
  53.     local float fItemCount;
  54.     local entity eTemp;
  55.  
  56.     self.model = self.mdl;        // restore original model
  57.     self.solid = SOLID_TRIGGER;    // allow it to be touched again
  58.     sound (self, CHAN_VOICE, "items/itembk2.wav", 1, ATTN_NORM);    // play respawn sound
  59.  
  60.     fItemCount=random()*20;
  61.  
  62.     eTemp=findradius(self.origin,10000);
  63.  
  64.     while (fItemCount>0)
  65.         {
  66.         eTemp=eTemp.chain;
  67.         fItemCount=fItemCount - 1;
  68.         if (!eTemp.chain)
  69.             {
  70.             setorigin (self,self.origin);
  71.             return;
  72.             }
  73.         }
  74.  
  75.     while (CheckEntity(eTemp)!=TRUE)
  76.         eTemp=eTemp.chain;
  77.  
  78.     vTemp=eTemp.origin;
  79.  
  80.     setorigin (eTemp,self.origin);
  81.     
  82.     setorigin (self, vTemp);
  83. };
  84.  
  85.  
  86.  
  87. /*QUAKED noclass (0 0 0) (-8 -8 -8) (8 8 8)
  88. prints a warning message when spawned
  89. */
  90. void() noclass =
  91. {
  92.     dprint ("noclass spawned at");
  93.     dprint (vtos(self.origin));
  94.     dprint ("\n");
  95.     remove (self);
  96. };
  97.  
  98.  
  99.  
  100. /*
  101. ============
  102. PlaceItem
  103.  
  104. plants the object on the floor
  105. ============
  106. */
  107. void() PlaceItem =
  108. {
  109.     local float    oldz;
  110.  
  111.     self.mdl = self.model;        // so it can be restored on respawn
  112.     self.flags = FL_ITEM;        // make extra wide
  113.     self.solid = SOLID_TRIGGER;
  114.     self.movetype = MOVETYPE_TOSS;    
  115.     self.velocity = '0 0 0';
  116.     self.origin_z = self.origin_z + 6;
  117.     oldz = self.origin_z;
  118.     if (!droptofloor())
  119.     {
  120.         dprint ("Bonus item fell out of level at ");
  121.         dprint (vtos(self.origin));
  122.         dprint ("\n");
  123.         remove(self);
  124.         return;
  125.     }
  126. };
  127.  
  128. /*
  129. ============
  130. StartItem
  131.  
  132. Sets the clipping size and plants the object on the floor
  133. ============
  134. */
  135. void() StartItem =
  136. {
  137.     self.nextthink = time + 0.2;    // items start after other solids
  138.     self.think = PlaceItem;
  139. };
  140.  
  141. /*
  142. =========================================================================
  143.  
  144. HEALTH BOX
  145.  
  146. =========================================================================
  147. */
  148. //
  149. // T_Heal: add health to an entity, limiting health to max_health
  150. // "ignore" will ignore max_health limit
  151. //
  152. float (entity e, float healamount, float ignore) T_Heal =
  153. {
  154.     if (e.health <= 0)
  155.         return 0;
  156.     if ((!ignore) && (e.health >= other.max_health))
  157.         return 0;
  158.     healamount = ceil(healamount);
  159.  
  160.     e.health = e.health + healamount;
  161.     if ((!ignore) && (e.health >= other.max_health))
  162.         e.health = other.max_health;
  163.         
  164.     if (e.health > 250)
  165.         e.health = 250;
  166.     return 1;
  167. };
  168.  
  169. /*QUAKED item_health (.3 .3 1) (0 0 0) (32 32 32) rotten megahealth
  170. Health box. Normally gives 25 points.
  171. Rotten box heals 5-10 points,
  172. megahealth will add 100 health, then 
  173. rot you down to your maximum health limit, 
  174. one point per second.
  175. */
  176.  
  177. float    H_ROTTEN = 1;
  178. float    H_MEGA = 2;
  179. .float    healamount, healtype;
  180. void() health_touch;
  181. void() item_megahealth_rot;
  182.  
  183. void() item_health =
  184. {    
  185.     self.touch = health_touch;
  186.  
  187.     if (self.spawnflags & H_ROTTEN)
  188.     {
  189.         precache_model("maps/b_bh10.bsp");
  190.  
  191.         precache_sound("items/r_item1.wav");
  192.         setmodel(self, "maps/b_bh10.bsp");
  193.         self.noise = "items/r_item1.wav";
  194.         self.healamount = 15;
  195.         self.healtype = 0;
  196.     }
  197.     else
  198.     if (self.spawnflags & H_MEGA)
  199.     {
  200.         precache_model("maps/b_bh100.bsp");
  201.         precache_sound("items/r_item2.wav");
  202.         setmodel(self, "maps/b_bh100.bsp");
  203.         self.noise = "items/r_item2.wav";
  204.         self.healamount = 100;
  205.         self.healtype = 2;
  206.     }
  207.     else
  208.     {
  209.         precache_model("maps/b_bh25.bsp");
  210.         precache_sound("items/health1.wav");
  211.         setmodel(self, "maps/b_bh25.bsp");
  212.         self.noise = "items/health1.wav";
  213.         self.healamount = 25;
  214.         self.healtype = 1;
  215.     }
  216.     setsize (self, '0 0 0', '32 32 56');
  217.     StartItem ();
  218. };
  219.  
  220.  
  221. void() health_touch =
  222. {
  223.     local    float amount;
  224.     local    string    s;
  225.     
  226.     if (other.classname != "player")
  227.         return;
  228.     
  229.     if (self.healtype == 2) // Megahealth?  Ignore max_health...
  230.     {
  231.         if (other.health >= 250)
  232.             return;
  233.         if (!T_Heal(other, self.healamount, 1))
  234.             return;
  235.     }
  236.     else
  237.     {
  238.         if (!T_Heal(other, self.healamount, 0))
  239.             return;
  240.     }
  241.     
  242.     sprint(other, "You receive ");
  243.     s = ftos(self.healamount);
  244.     sprint(other, s);
  245.     sprint(other, " health\n");
  246.     
  247. // health touch sound
  248.     sound(other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  249.  
  250.     stuffcmd (other, "bf\n");
  251.     
  252.     self.model = string_null;
  253.     self.solid = SOLID_NOT;
  254.  
  255.     // Megahealth = rot down the player's super health
  256.     if (self.healtype == 2)
  257.     {
  258.         other.items = other.items | IT_SUPERHEALTH;
  259.         self.nextthink = time + 5;
  260.         self.think = item_megahealth_rot;
  261.         self.owner = other;
  262.     }
  263.     else
  264.     {
  265.         if (deathmatch != 2)        // deathmatch 2 is the silly old rules
  266.         {
  267.             if (deathmatch)
  268.                 self.nextthink = time + 20;
  269.             self.think = SUB_regen;
  270.         }
  271.     }
  272.     
  273.     activator = other;
  274.     SUB_UseTargets();                // fire all targets / killtargets
  275. };    
  276.  
  277. void() item_megahealth_rot =
  278. {
  279.     other = self.owner;
  280.     
  281.     if (other.health > other.max_health)
  282.     {
  283.         other.health = other.health - 1;
  284.         self.nextthink = time + 1;
  285.         return;
  286.     }
  287.  
  288. // it is possible for a player to die and respawn between rots, so don't
  289. // just blindly subtract the flag off
  290.     other.items = other.items - (other.items & IT_SUPERHEALTH);
  291.     
  292.     if (deathmatch == 1)    // deathmatch 2 is silly old rules
  293.     {
  294.         self.nextthink = time + 20;
  295.         self.think = SUB_regen;
  296.     }
  297. };
  298.  
  299. /*
  300. ===============================================================================
  301.  
  302. ARMOR
  303.  
  304. ===============================================================================
  305. */
  306.  
  307. void() armor_touch;
  308.  
  309. void() armor_touch =
  310. {
  311.     local    float    type, value, bit;
  312.     
  313.     if (other.health <= 0)
  314.         return;
  315.     if (other.classname != "player")
  316.         return;
  317.  
  318.     if (self.classname == "item_armor1")
  319.     {
  320.         type = 0.3;
  321.         value = 100;
  322.         bit = IT_ARMOR1;
  323.     }
  324.     if (self.classname == "item_armor2")
  325.     {
  326.         type = 0.6;
  327.         value = 150;
  328.         bit = IT_ARMOR2;
  329.     }
  330.     if (self.classname == "item_armorInv")
  331.     {
  332.         type = 0.8;
  333.         value = 200;
  334.         bit = IT_ARMOR3;
  335.     }
  336.     if (other.armortype*other.armorvalue >= type*value)
  337.         return;
  338.         
  339.     other.armortype = type;
  340.     other.armorvalue = value;
  341.     other.items = other.items - (other.items & (IT_ARMOR1 | IT_ARMOR2 | IT_ARMOR3)) + bit;
  342.  
  343.     self.solid = SOLID_NOT;
  344.     self.model = string_null;
  345.     if (deathmatch == 1)
  346.         self.nextthink = time + 20;
  347.     self.think = SUB_regen;
  348.  
  349.     sprint(other, "You got armor\n");
  350. // armor touch sound
  351.     sound(other, CHAN_ITEM, "items/armor1.wav", 1, ATTN_NORM);
  352.     stuffcmd (other, "bf\n");
  353.     
  354.     activator = other;
  355.     SUB_UseTargets();                // fire all targets / killtargets
  356. };
  357.  
  358.  
  359. /*QUAKED item_armor1 (0 .5 .8) (-16 -16 0) (16 16 32)
  360. */
  361.  
  362. void() item_armor1 =
  363. {
  364.     self.touch = armor_touch;
  365.     precache_model ("progs/armor.mdl");
  366.     setmodel (self, "progs/armor.mdl");
  367.     self.skin = 0;
  368.     setsize (self, '-16 -16 0', '16 16 56');
  369.     StartItem ();
  370. };
  371.  
  372. /*QUAKED item_armor2 (0 .5 .8) (-16 -16 0) (16 16 32)
  373. */
  374.  
  375. void() item_armor2 =
  376. {
  377.     self.touch = armor_touch;
  378.     precache_model ("progs/armor.mdl");
  379.     setmodel (self, "progs/armor.mdl");
  380.     self.skin = 1;
  381.     setsize (self, '-16 -16 0', '16 16 56');
  382.     StartItem ();
  383. };
  384.  
  385. /*QUAKED item_armorInv (0 .5 .8) (-16 -16 0) (16 16 32)
  386. */
  387.  
  388. void() item_armorInv =
  389. {
  390.     self.touch = armor_touch;
  391.     precache_model ("progs/armor.mdl");
  392.     setmodel (self, "progs/armor.mdl");
  393.     self.skin = 2;
  394.     setsize (self, '-16 -16 0', '16 16 56');
  395.     StartItem ();
  396. };
  397.  
  398. /*
  399. ===============================================================================
  400.  
  401. WEAPONS
  402.  
  403. ===============================================================================
  404. */
  405.  
  406. void() bound_other_ammo =
  407. {
  408.     if (other.ammo_shells > 100)
  409.         other.ammo_shells = 100;
  410.     if (other.ammo_nails > 200)
  411.         other.ammo_nails = 200;
  412.     if (other.ammo_rockets > 100)
  413.         other.ammo_rockets = 100;        
  414.     if (other.ammo_cells > 100)
  415.         other.ammo_cells = 100;        
  416. };
  417.  
  418.  
  419. float(float w) RankForWeapon =
  420. {
  421.     if (w == IT_LIGHTNING)
  422.         return 1;
  423.     if (w == IT_ROCKET_LAUNCHER)
  424.         return 2;
  425.     if (w == IT_SUPER_NAILGUN)
  426.         return 3;
  427.     if (w == IT_GRENADE_LAUNCHER)
  428.         return 4;
  429.     if (w == IT_SUPER_SHOTGUN)
  430.         return 5;
  431.     if (w == IT_NAILGUN)
  432.         return 6;
  433.     return 7;
  434. };
  435.  
  436. /*
  437. =============
  438. Deathmatch_Weapon
  439.  
  440. Deathmatch weapon change rules for picking up a weapon
  441.  
  442. .float        ammo_shells, ammo_nails, ammo_rockets, ammo_cells;
  443. =============
  444. */
  445. void(float old, float new) Deathmatch_Weapon =
  446. {
  447.     local float or, nr;
  448.  
  449. // change self.weapon if desired
  450.     or = RankForWeapon (self.weapon);
  451.     nr = RankForWeapon (new);
  452.     if ( nr < or )
  453.         self.weapon = new;
  454. };
  455.  
  456. /*
  457. =============
  458. weapon_touch
  459. =============
  460. */
  461. float() W_BestWeapon;
  462.  
  463. void() weapon_touch =
  464. {
  465.     local    float    hadammo, best, new, old;
  466.     local    entity    stemp;
  467.     local    float    leave;
  468.  
  469.     if (!(other.flags & FL_CLIENT))
  470.         return;
  471.  
  472. // if the player was using his best weapon, change up to the new one if better        
  473.     stemp = self;
  474.     self = other;
  475.     best = W_BestWeapon();
  476.     self = stemp;
  477.  
  478.     if (deathmatch == 2 || coop)
  479.         leave = 1;
  480.     else
  481.         leave = 0;
  482.     
  483.     if (self.classname == "weapon_nailgun")
  484.     {
  485.         if (leave && (other.items & IT_NAILGUN) )
  486.             return;
  487.         hadammo = other.ammo_nails;            
  488.         new = IT_NAILGUN;
  489.         other.ammo_nails = other.ammo_nails + 30;
  490.     }
  491.     else if (self.classname == "weapon_supernailgun")
  492.     {
  493.         if (leave && (other.items & IT_SUPER_NAILGUN) )
  494.             return;
  495.         hadammo = other.ammo_rockets;            
  496.         new = IT_SUPER_NAILGUN;
  497.         other.ammo_nails = other.ammo_nails + 30;
  498.     }
  499.     else if (self.classname == "weapon_supershotgun")
  500.     {
  501.         if (leave && (other.items & IT_SUPER_SHOTGUN) )
  502.             return;
  503.         hadammo = other.ammo_rockets;            
  504.         new = IT_SUPER_SHOTGUN;
  505.         other.ammo_shells = other.ammo_shells + 5;
  506.     }
  507.     else if (self.classname == "weapon_rocketlauncher")
  508.     {
  509.         if (leave && (other.items & IT_ROCKET_LAUNCHER) )
  510.             return;
  511.         hadammo = other.ammo_rockets;            
  512.         new = IT_ROCKET_LAUNCHER;
  513.         other.ammo_rockets = other.ammo_rockets + 5;
  514.     }
  515.     else if (self.classname == "weapon_grenadelauncher")
  516.     {
  517.         if (leave && (other.items & IT_GRENADE_LAUNCHER) )
  518.             return;
  519.         hadammo = other.ammo_rockets;            
  520.         new = IT_GRENADE_LAUNCHER;
  521.         other.ammo_rockets = other.ammo_rockets + 5;
  522.     }
  523.     else if (self.classname == "weapon_lightning")
  524.     {
  525.         if (leave && (other.items & IT_LIGHTNING) )
  526.             return;
  527.         hadammo = other.ammo_rockets;            
  528.         new = IT_LIGHTNING;
  529.         other.ammo_cells = other.ammo_cells + 15;
  530.     }
  531.     else
  532.         objerror ("weapon_touch: unknown classname");
  533.  
  534.     sprint (other, "You got the ");
  535.     sprint (other, self.netname);
  536.     sprint (other, "\n");
  537. // weapon touch sound
  538.     sound (other, CHAN_ITEM, "weapons/pkup.wav", 1, ATTN_NORM);
  539.     stuffcmd (other, "bf\n");
  540.  
  541.     bound_other_ammo ();
  542.  
  543. // change to the weapon
  544.     old = other.items;
  545.     other.items = other.items | new;
  546.     
  547.     stemp = self;
  548.     self = other;
  549.  
  550.     if (!deathmatch)
  551.         self.weapon = new;
  552.     else
  553.         Deathmatch_Weapon (old, new);
  554.  
  555.     W_SetCurrentAmmo();
  556.  
  557.     self = stemp;
  558.  
  559.     if (leave)
  560.         return;
  561.  
  562. // remove it in single player, or setup for respawning in deathmatch
  563.     self.model = string_null;
  564.     self.solid = SOLID_NOT;
  565.     if (deathmatch == 1)
  566.         self.nextthink = time + 30;
  567.     self.think = SUB_regen;
  568.     
  569.     activator = other;
  570.     SUB_UseTargets();                // fire all targets / killtargets
  571. };
  572.  
  573.  
  574. /*QUAKED weapon_supershotgun (0 .5 .8) (-16 -16 0) (16 16 32)
  575. */
  576.  
  577. void() weapon_supershotgun =
  578. {
  579.     precache_model ("progs/g_shot.mdl");
  580.     setmodel (self, "progs/g_shot.mdl");
  581.     self.weapon = IT_SUPER_SHOTGUN;
  582.     self.netname = "Double-barrelled Shotgun";
  583.     self.touch = weapon_touch;
  584.     setsize (self, '-16 -16 0', '16 16 56');
  585.     StartItem ();
  586. };
  587.  
  588. /*QUAKED weapon_nailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  589. */
  590.  
  591. void() weapon_nailgun =
  592. {
  593.     precache_model ("progs/g_nail.mdl");
  594.     setmodel (self, "progs/g_nail.mdl");
  595.     self.weapon = IT_NAILGUN;
  596.     self.netname = "nailgun";
  597.     self.touch = weapon_touch;
  598.     setsize (self, '-16 -16 0', '16 16 56');
  599.     StartItem ();
  600. };
  601.  
  602. /*QUAKED weapon_supernailgun (0 .5 .8) (-16 -16 0) (16 16 32)
  603. */
  604.  
  605. void() weapon_supernailgun =
  606. {
  607.     precache_model ("progs/g_nail2.mdl");
  608.     setmodel (self, "progs/g_nail2.mdl");
  609.     self.weapon = IT_SUPER_NAILGUN;
  610.     self.netname = "Super Nailgun";
  611.     self.touch = weapon_touch;
  612.     setsize (self, '-16 -16 0', '16 16 56');
  613.     StartItem ();
  614. };
  615.  
  616. /*QUAKED weapon_grenadelauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  617. */
  618.  
  619. void() weapon_grenadelauncher =
  620. {
  621.     precache_model ("progs/g_rock.mdl");
  622.     setmodel (self, "progs/g_rock.mdl");
  623.     self.weapon = 3;
  624.     self.netname = "Grenade Launcher";
  625.     self.touch = weapon_touch;
  626.     setsize (self, '-16 -16 0', '16 16 56');
  627.     StartItem ();
  628. };
  629.  
  630. /*QUAKED weapon_rocketlauncher (0 .5 .8) (-16 -16 0) (16 16 32)
  631. */
  632.  
  633. void() weapon_rocketlauncher =
  634. {
  635.     precache_model ("progs/g_rock2.mdl");
  636.     setmodel (self, "progs/g_rock2.mdl");
  637.     self.weapon = 3;
  638.     self.netname = "Rocket Launcher";
  639.     self.touch = weapon_touch;
  640.     setsize (self, '-16 -16 0', '16 16 56');
  641.     StartItem ();
  642. };
  643.  
  644.  
  645. /*QUAKED weapon_lightning (0 .5 .8) (-16 -16 0) (16 16 32)
  646. */
  647.  
  648. void() weapon_lightning =
  649. {
  650.     precache_model ("progs/g_light.mdl");
  651.     setmodel (self, "progs/g_light.mdl");
  652.     self.weapon = 3;
  653.     self.netname = "Thunderbolt";
  654.     self.touch = weapon_touch;
  655.     setsize (self, '-16 -16 0', '16 16 56');
  656.     StartItem ();
  657. };
  658.  
  659.  
  660. /*
  661. ===============================================================================
  662.  
  663. AMMO
  664.  
  665. ===============================================================================
  666. */
  667.  
  668. void() ammo_touch =
  669. {
  670. local entity    stemp;
  671. local float        best;
  672.  
  673.     if (other.classname != "player")
  674.         return;
  675.     if (other.health <= 0)
  676.         return;
  677.  
  678. // if the player was using his best weapon, change up to the new one if better        
  679.     stemp = self;
  680.     self = other;
  681.     best = W_BestWeapon();
  682.     self = stemp;
  683.  
  684.  
  685. // shotgun
  686.     if (self.weapon == 1)
  687.     {
  688.         if (other.ammo_shells >= 100)
  689.             return;
  690.         other.ammo_shells = other.ammo_shells + self.aflag;
  691.     }
  692.  
  693. // spikes
  694.     if (self.weapon == 2)
  695.     {
  696.         if (other.ammo_nails >= 200)
  697.             return;
  698.         other.ammo_nails = other.ammo_nails + self.aflag;
  699.     }
  700.  
  701. //    rockets
  702.     if (self.weapon == 3)
  703.     {
  704.         if (other.ammo_rockets >= 100)
  705.             return;
  706.         other.ammo_rockets = other.ammo_rockets + self.aflag;
  707.     }
  708.  
  709. //    cells
  710.     if (self.weapon == 4)
  711.     {
  712.         if (other.ammo_cells >= 200)
  713.             return;
  714.         other.ammo_cells = other.ammo_cells + self.aflag;
  715.     }
  716.  
  717.     bound_other_ammo ();
  718.     
  719.     sprint (other, "You got the ");
  720.     sprint (other, self.netname);
  721.     sprint (other, "\n");
  722. // ammo touch sound
  723.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  724.     stuffcmd (other, "bf\n");
  725.  
  726. // change to a better weapon if appropriate
  727.  
  728.     if ( other.weapon == best )
  729.     {
  730.         stemp = self;
  731.         self = other;
  732.         self.weapon = W_BestWeapon();
  733.         W_SetCurrentAmmo ();
  734.         self = stemp;
  735.     }
  736.  
  737. // if changed current ammo, update it
  738.     stemp = self;
  739.     self = other;
  740.     W_SetCurrentAmmo();
  741.     self = stemp;
  742.  
  743. // remove it in single player, or setup for respawning in deathmatch
  744.     self.model = string_null;
  745.     self.solid = SOLID_NOT;
  746.     if (deathmatch == 1)
  747.         self.nextthink = time + 30;
  748.     
  749.     self.think = SUB_regen;
  750.  
  751.     activator = other;
  752.     SUB_UseTargets();                // fire all targets / killtargets
  753. };
  754.  
  755.  
  756.  
  757.  
  758. float WEAPON_BIG2 = 1;
  759.  
  760. /*QUAKED item_shells (0 .5 .8) (0 0 0) (32 32 32) big
  761. */
  762.  
  763. void() item_shells =
  764. {
  765.     self.touch = ammo_touch;
  766.  
  767.     if (self.spawnflags & WEAPON_BIG2)
  768.     {
  769.         precache_model ("maps/b_shell1.bsp");
  770.         setmodel (self, "maps/b_shell1.bsp");
  771.         self.aflag = 40;
  772.     }
  773.     else
  774.     {
  775.         precache_model ("maps/b_shell0.bsp");
  776.         setmodel (self, "maps/b_shell0.bsp");
  777.         self.aflag = 20;
  778.     }
  779.     self.weapon = 1;
  780.     self.netname = "shells";
  781.     setsize (self, '0 0 0', '32 32 56');
  782.     StartItem ();
  783. };
  784.  
  785. /*QUAKED item_spikes (0 .5 .8) (0 0 0) (32 32 32) big
  786. */
  787.  
  788. void() item_spikes =
  789. {
  790.     self.touch = ammo_touch;
  791.  
  792.     if (self.spawnflags & WEAPON_BIG2)
  793.     {
  794.         precache_model ("maps/b_nail1.bsp");
  795.         setmodel (self, "maps/b_nail1.bsp");
  796.         self.aflag = 50;
  797.     }
  798.     else
  799.     {
  800.         precache_model ("maps/b_nail0.bsp");
  801.         setmodel (self, "maps/b_nail0.bsp");
  802.         self.aflag = 25;
  803.     }
  804.     self.weapon = 2;
  805.     self.netname = "nails";
  806.     setsize (self, '0 0 0', '32 32 56');
  807.     StartItem ();
  808. };
  809.  
  810. /*QUAKED item_rockets (0 .5 .8) (0 0 0) (32 32 32) big
  811. */
  812.  
  813. void() item_rockets =
  814. {
  815.     self.touch = ammo_touch;
  816.  
  817.     if (self.spawnflags & WEAPON_BIG2)
  818.     {
  819.         precache_model ("maps/b_rock1.bsp");
  820.         setmodel (self, "maps/b_rock1.bsp");
  821.         self.aflag = 10;
  822.     }
  823.     else
  824.     {
  825.         precache_model ("maps/b_rock0.bsp");
  826.         setmodel (self, "maps/b_rock0.bsp");
  827.         self.aflag = 5;
  828.     }
  829.     self.weapon = 3;
  830.     self.netname = "rockets";
  831.     setsize (self, '0 0 0', '32 32 56');
  832.     StartItem ();
  833. };
  834.  
  835.  
  836. /*QUAKED item_cells (0 .5 .8) (0 0 0) (32 32 32) big
  837. */
  838.  
  839. void() item_cells =
  840. {
  841.     self.touch = ammo_touch;
  842.  
  843.     if (self.spawnflags & WEAPON_BIG2)
  844.     {
  845.         precache_model ("maps/b_batt1.bsp");
  846.         setmodel (self, "maps/b_batt1.bsp");
  847.         self.aflag = 12;
  848.     }
  849.     else
  850.     {
  851.         precache_model ("maps/b_batt0.bsp");
  852.         setmodel (self, "maps/b_batt0.bsp");
  853.         self.aflag = 6;
  854.     }
  855.     self.weapon = 4;
  856.     self.netname = "cells";
  857.     setsize (self, '0 0 0', '32 32 56');
  858.     StartItem ();
  859. };
  860.  
  861.  
  862. /*QUAKED item_weapon (0 .5 .8) (0 0 0) (32 32 32) shotgun rocket spikes big
  863. DO NOT USE THIS!!!! IT WILL BE REMOVED!
  864. */
  865.  
  866. float WEAPON_SHOTGUN = 1;
  867. float WEAPON_ROCKET = 2;
  868. float WEAPON_SPIKES = 4;
  869. float WEAPON_BIG = 8;
  870. void() item_weapon =
  871. {
  872.     self.touch = ammo_touch;
  873.  
  874.     if (self.spawnflags & WEAPON_SHOTGUN)
  875.     {
  876.         if (self.spawnflags & WEAPON_BIG)
  877.         {
  878.             precache_model ("maps/b_shell1.bsp");
  879.             setmodel (self, "maps/b_shell1.bsp");
  880.             self.aflag = 40;
  881.         }
  882.         else
  883.         {
  884.             precache_model ("maps/b_shell0.bsp");
  885.             setmodel (self, "maps/b_shell0.bsp");
  886.             self.aflag = 20;
  887.         }
  888.         self.weapon = 1;
  889.         self.netname = "shells";
  890.     }
  891.  
  892.     if (self.spawnflags & WEAPON_SPIKES)
  893.     {
  894.         if (self.spawnflags & WEAPON_BIG)
  895.         {
  896.             precache_model ("maps/b_nail1.bsp");
  897.             setmodel (self, "maps/b_nail1.bsp");
  898.             self.aflag = 40;
  899.         }
  900.         else
  901.         {
  902.             precache_model ("maps/b_nail0.bsp");
  903.             setmodel (self, "maps/b_nail0.bsp");
  904.             self.aflag = 20;
  905.         }
  906.         self.weapon = 2;
  907.         self.netname = "spikes";
  908.     }
  909.  
  910.     if (self.spawnflags & WEAPON_ROCKET)
  911.     {
  912.         if (self.spawnflags & WEAPON_BIG)
  913.         {
  914.             precache_model ("maps/b_rock1.bsp");
  915.             setmodel (self, "maps/b_rock1.bsp");
  916.             self.aflag = 10;
  917.         }
  918.         else
  919.         {
  920.             precache_model ("maps/b_rock0.bsp");
  921.             setmodel (self, "maps/b_rock0.bsp");
  922.             self.aflag = 5;
  923.         }
  924.         self.weapon = 3;
  925.         self.netname = "rockets";
  926.     }
  927.     
  928.     setsize (self, '0 0 0', '32 32 56');
  929.     StartItem ();
  930. };
  931.  
  932.  
  933. /*
  934. ===============================================================================
  935.  
  936. KEYS
  937.  
  938. ===============================================================================
  939. */
  940.  
  941. void() key_touch =
  942. {
  943. local entity    stemp;
  944. local float        best;
  945.  
  946.     if (other.classname != "player")
  947.         return;
  948.     if (other.health <= 0)
  949.         return;
  950.     if (other.items & self.items)
  951.         return;
  952.  
  953.     sprint (other, "You got the ");
  954.     sprint (other, self.netname);
  955.     sprint (other,"\n");
  956.  
  957.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  958.     stuffcmd (other, "bf\n");
  959.     other.items = other.items | self.items;
  960.  
  961.     if (!coop)
  962.     {    
  963.         self.solid = SOLID_NOT;
  964.         self.model = string_null;
  965.     }
  966.  
  967.     activator = other;
  968.     SUB_UseTargets();                // fire all targets / killtargets
  969. };
  970.  
  971.  
  972. void() key_setsounds =
  973. {
  974.     if (world.worldtype == 0)
  975.     {
  976.         precache_sound ("misc/medkey.wav");
  977.         self.noise = "misc/medkey.wav";
  978.     }
  979.     if (world.worldtype == 1)
  980.     {
  981.         precache_sound ("misc/runekey.wav");
  982.         self.noise = "misc/runekey.wav";
  983.     }
  984.     if (world.worldtype == 2)
  985.     {
  986.         precache_sound2 ("misc/basekey.wav");
  987.         self.noise = "misc/basekey.wav";
  988.     }
  989. };
  990.  
  991. /*QUAKED item_key1 (0 .5 .8) (-16 -16 -24) (16 16 32)
  992. SILVER key
  993. In order for keys to work
  994. you MUST set your maps
  995. worldtype to one of the
  996. following:
  997. 0: medieval
  998. 1: metal
  999. 2: base
  1000. */
  1001.  
  1002. void() item_key1 =
  1003. {
  1004.     if (world.worldtype == 0)
  1005.     {
  1006.         precache_model ("progs/w_s_key.mdl");
  1007.         setmodel (self, "progs/w_s_key.mdl");
  1008.         self.netname = "silver key";
  1009.     }
  1010.     else if (world.worldtype == 1)
  1011.     {
  1012.         precache_model ("progs/m_s_key.mdl");
  1013.         setmodel (self, "progs/m_s_key.mdl");
  1014.         self.netname = "silver runekey";
  1015.     }
  1016.     else if (world.worldtype == 2)
  1017.     {
  1018.         precache_model2 ("progs/b_s_key.mdl");
  1019.         setmodel (self, "progs/b_s_key.mdl");
  1020.         self.netname = "silver keycard";
  1021.     }
  1022.     key_setsounds();
  1023.     self.touch = key_touch;
  1024.     self.items = IT_KEY1;
  1025.     setsize (self, '-16 -16 -24', '16 16 32');
  1026.     StartItem ();
  1027. };
  1028.  
  1029. /*QUAKED item_key2 (0 .5 .8) (-16 -16 -24) (16 16 32)
  1030. GOLD key
  1031. In order for keys to work
  1032. you MUST set your maps
  1033. worldtype to one of the
  1034. following:
  1035. 0: medieval
  1036. 1: metal
  1037. 2: base
  1038. */
  1039.  
  1040. void() item_key2 =
  1041. {
  1042.     if (world.worldtype == 0)
  1043.     {
  1044.         precache_model ("progs/w_g_key.mdl");
  1045.         setmodel (self, "progs/w_g_key.mdl");
  1046.         self.netname = "gold key";
  1047.     }
  1048.     if (world.worldtype == 1)
  1049.     {
  1050.         precache_model ("progs/m_g_key.mdl");
  1051.         setmodel (self, "progs/m_g_key.mdl");
  1052.         self.netname = "gold runekey";
  1053.     }
  1054.     if (world.worldtype == 2)
  1055.     {
  1056.         precache_model2 ("progs/b_g_key.mdl");
  1057.         setmodel (self, "progs/b_g_key.mdl");
  1058.         self.netname = "gold keycard";
  1059.     }
  1060.     key_setsounds();
  1061.     self.touch = key_touch;
  1062.     self.items = IT_KEY2;
  1063.     setsize (self, '-16 -16 -24', '16 16 32');
  1064.     StartItem ();
  1065. };
  1066.  
  1067.  
  1068.  
  1069. /*
  1070. ===============================================================================
  1071.  
  1072. END OF LEVEL RUNES
  1073.  
  1074. ===============================================================================
  1075. */
  1076.  
  1077. void() sigil_touch =
  1078. {
  1079. local entity    stemp;
  1080. local float        best;
  1081.  
  1082.     if (other.classname != "player")
  1083.         return;
  1084.     if (other.health <= 0)
  1085.         return;
  1086.  
  1087.     centerprint (other, "You got the rune!");
  1088.  
  1089.     sound (other, CHAN_ITEM, self.noise, 1, ATTN_NORM);
  1090.     stuffcmd (other, "bf\n");
  1091.     self.solid = SOLID_NOT;
  1092.     self.model = string_null;
  1093.     serverflags = serverflags | (self.spawnflags & 15);
  1094.     self.classname = "";        // so rune doors won't find it
  1095.     
  1096.     activator = other;
  1097.     SUB_UseTargets();                // fire all targets / killtargets
  1098. };
  1099.  
  1100.  
  1101. /*QUAKED item_sigil (0 .5 .8) (-16 -16 -24) (16 16 32) E1 E2 E3 E4
  1102. End of level sigil, pick up to end episode and return to jrstart.
  1103. */
  1104.  
  1105. void() item_sigil =
  1106. {
  1107.     if (!self.spawnflags)
  1108.         objerror ("no spawnflags");
  1109.  
  1110.     precache_sound ("misc/runekey.wav");
  1111.     self.noise = "misc/runekey.wav";
  1112.  
  1113.     if (self.spawnflags & 1)
  1114.     {
  1115.         precache_model ("progs/end1.mdl");
  1116.         setmodel (self, "progs/end1.mdl");
  1117.     }
  1118.     if (self.spawnflags & 2)
  1119.     {
  1120.         precache_model2 ("progs/end2.mdl");
  1121.         setmodel (self, "progs/end2.mdl");
  1122.     }
  1123.     if (self.spawnflags & 4)
  1124.     {
  1125.         precache_model2 ("progs/end3.mdl");
  1126.         setmodel (self, "progs/end3.mdl");
  1127.     }
  1128.     if (self.spawnflags & 8)
  1129.     {
  1130.         precache_model2 ("progs/end4.mdl");
  1131.         setmodel (self, "progs/end4.mdl");
  1132.     }
  1133.     
  1134.     self.touch = sigil_touch;
  1135.     setsize (self, '-16 -16 -24', '16 16 32');
  1136.     StartItem ();
  1137. };
  1138.  
  1139. /*
  1140. ===============================================================================
  1141.  
  1142. POWERUPS
  1143.  
  1144. ===============================================================================
  1145. */
  1146.  
  1147. void() powerup_touch;
  1148.  
  1149.  
  1150. void() powerup_touch =
  1151. {
  1152. local entity    stemp;
  1153. local float        best;
  1154.  
  1155.     if (other.classname != "player")
  1156.         return;
  1157.     if (other.health <= 0)
  1158.         return;
  1159.  
  1160.     sprint (other, "You got the ");
  1161.     sprint (other, self.netname);
  1162.     sprint (other,"\n");
  1163.  
  1164.     if (deathmatch)
  1165.     {
  1166.         self.mdl = self.model;
  1167.         
  1168.         if ((self.classname == "item_artifact_invulnerability") ||
  1169.             (self.classname == "item_artifact_invisibility"))
  1170.             self.nextthink = time + 60*5;
  1171.         else
  1172.             self.nextthink = time + 60;
  1173.         
  1174.         self.think = SUB_regen;
  1175.     }    
  1176.  
  1177.     sound (other, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  1178.     stuffcmd (other, "bf\n");
  1179.     self.solid = SOLID_NOT;
  1180.     other.items = other.items | self.items;
  1181.     self.model = string_null;
  1182.  
  1183. // do the apropriate action
  1184.     if (self.classname == "item_artifact_envirosuit")
  1185.     {
  1186.         other.rad_time = 1;
  1187.         other.radsuit_finished = time + 30;
  1188.     }
  1189.     
  1190.     if (self.classname == "item_artifact_invulnerability")
  1191.     {
  1192.         other.invincible_time = 1;
  1193.         other.invincible_finished = time + 30;
  1194.     }
  1195.     
  1196.     if (self.classname == "item_artifact_invisibility")
  1197.     {
  1198.         other.invisible_time = 1;
  1199.         other.invisible_finished = time + 30;
  1200.     }
  1201.  
  1202.     if (self.classname == "item_artifact_super_damage")
  1203.     {
  1204.         other.super_time = 1;
  1205.         other.super_damage_finished = time + 30;
  1206.     }    
  1207.  
  1208.     activator = other;
  1209.     SUB_UseTargets();                // fire all targets / killtargets
  1210. };
  1211.  
  1212.  
  1213.  
  1214. /*QUAKED item_artifact_invulnerability (0 .5 .8) (-16 -16 -24) (16 16 32)
  1215. Player is invulnerable for 30 seconds
  1216. */
  1217. void() item_artifact_invulnerability =
  1218. {
  1219.     self.touch = powerup_touch;
  1220.  
  1221.     precache_model ("progs/invulner.mdl");
  1222.     precache_sound ("items/protect.wav");
  1223.     precache_sound ("items/protect2.wav");
  1224.     precache_sound ("items/protect3.wav");
  1225.     self.noise = "items/protect.wav";
  1226.     setmodel (self, "progs/invulner.mdl");
  1227.     self.netname = "Pentagram of Protection";
  1228.     self.items = IT_INVULNERABILITY;
  1229.     setsize (self, '-16 -16 -24', '16 16 32');
  1230.     StartItem ();
  1231. };
  1232.  
  1233. /*QUAKED item_artifact_envirosuit (0 .5 .8) (-16 -16 -24) (16 16 32)
  1234. Player takes no damage from water or slime for 30 seconds
  1235. */
  1236. void() item_artifact_envirosuit =
  1237. {
  1238.     self.touch = powerup_touch;
  1239.  
  1240.     precache_model ("progs/suit.mdl");
  1241.     precache_sound ("items/suit.wav");
  1242.     precache_sound ("items/suit2.wav");
  1243.     self.noise = "items/suit.wav";
  1244.     setmodel (self, "progs/suit.mdl");
  1245.     self.netname = "Biosuit";
  1246.     self.items = IT_SUIT;
  1247.     setsize (self, '-16 -16 -24', '16 16 32');
  1248.     StartItem ();
  1249. };
  1250.  
  1251.  
  1252. /*QUAKED item_artifact_invisibility (0 .5 .8) (-16 -16 -24) (16 16 32)
  1253. Player is invisible for 30 seconds
  1254. */
  1255. void() item_artifact_invisibility =
  1256. {
  1257.     self.touch = powerup_touch;
  1258.  
  1259.     precache_model ("progs/invisibl.mdl");
  1260.     precache_sound ("items/inv1.wav");
  1261.     precache_sound ("items/inv2.wav");
  1262.     precache_sound ("items/inv3.wav");
  1263.     self.noise = "items/inv1.wav";
  1264.     setmodel (self, "progs/invisibl.mdl");
  1265.     self.netname = "Ring of Shadows";
  1266.     self.items = IT_INVISIBILITY;
  1267.     setsize (self, '-16 -16 -24', '16 16 32');
  1268.     StartItem ();
  1269. };
  1270.  
  1271.  
  1272. /*QUAKED item_artifact_super_damage (0 .5 .8) (-16 -16 -24) (16 16 32)
  1273. The next attack from the player will do 4x damage
  1274. */
  1275. void() item_artifact_super_damage =
  1276. {
  1277.     self.touch = powerup_touch;
  1278.  
  1279.     precache_model ("progs/quaddama.mdl");
  1280.     precache_sound ("items/damage.wav");
  1281.     precache_sound ("items/damage2.wav");
  1282.     precache_sound ("items/damage3.wav");
  1283.     self.noise = "items/damage.wav";
  1284.     setmodel (self, "progs/quaddama.mdl");
  1285.     self.netname = "Quad Damage";
  1286.     self.items = IT_QUAD;
  1287.     setsize (self, '-16 -16 -24', '16 16 32');
  1288.     StartItem ();
  1289. };
  1290.  
  1291.  
  1292.  
  1293. /*
  1294. ===============================================================================
  1295.  
  1296. PLAYER BACKPACKS
  1297.  
  1298. ===============================================================================
  1299. */
  1300.  
  1301. void() BackpackTouch =
  1302. {
  1303.     local string    s;
  1304.     local    float    best;
  1305.     local        entity    stemp;
  1306.     
  1307.     if (other.classname != "player")
  1308.         return;
  1309.     if (other.health <= 0)
  1310.         return;
  1311.         
  1312. // if the player was using his best weapon, change up to the new one if better        
  1313.     stemp = self;
  1314.     self = other;
  1315.     best = W_BestWeapon();
  1316.     self = stemp;
  1317.  
  1318. // change weapons
  1319.     other.ammo_shells = other.ammo_shells + self.ammo_shells;
  1320.     other.ammo_nails = other.ammo_nails + self.ammo_nails;
  1321.     other.ammo_rockets = other.ammo_rockets + self.ammo_rockets;
  1322.     other.ammo_cells = other.ammo_cells + self.ammo_cells;
  1323.  
  1324.     other.items = other.items | self.items;
  1325.     
  1326.     bound_other_ammo ();
  1327.  
  1328.     sprint (other, "You get ");
  1329.  
  1330.     if (self.ammo_shells)
  1331.     {
  1332.         s = ftos(self.ammo_shells);
  1333.         sprint (other, s);
  1334.         sprint (other, " shells  ");
  1335.     }
  1336.     if (self.ammo_nails)
  1337.     {
  1338.         s = ftos(self.ammo_nails);
  1339.         sprint (other, s);
  1340.         sprint (other, " nails ");
  1341.     }
  1342.     if (self.ammo_rockets)
  1343.     {
  1344.         s = ftos(self.ammo_rockets);
  1345.         sprint (other, s);
  1346.         sprint (other, " rockets  ");
  1347.     }
  1348.     if (self.ammo_cells)
  1349.     {
  1350.         s = ftos(self.ammo_cells);
  1351.         sprint (other, s);
  1352.         sprint (other, " cells  ");
  1353.     }
  1354.     
  1355.     sprint (other, "\n");
  1356. // backpack touch sound
  1357.     sound (other, CHAN_ITEM, "weapons/lock4.wav", 1, ATTN_NORM);
  1358.     stuffcmd (other, "bf\n");
  1359.  
  1360. // change to a better weapon if appropriate
  1361.     if ( other.weapon == best )
  1362.     {
  1363.         stemp = self;
  1364.         self = other;
  1365.         self.weapon = W_BestWeapon();
  1366.         self = stemp;
  1367.     }
  1368.  
  1369.     
  1370.     remove(self);
  1371.     
  1372.     self = other;
  1373.     W_SetCurrentAmmo ();
  1374. };
  1375.  
  1376. /*
  1377. ===============
  1378. DropBackpack
  1379. ===============
  1380. */
  1381. void() DropBackpack =
  1382. {
  1383.     local entity    item;
  1384.  
  1385.     if (!(self.ammo_shells + self.ammo_nails + self.ammo_rockets + self.ammo_cells))
  1386.         return;    // nothing in it
  1387.  
  1388.     item = spawn();
  1389.     item.origin = self.origin - '0 0 24';
  1390.     
  1391.     item.items = self.weapon;
  1392.  
  1393.     item.ammo_shells = self.ammo_shells;
  1394.     item.ammo_nails = self.ammo_nails;
  1395.     item.ammo_rockets = self.ammo_rockets;
  1396.     item.ammo_cells = self.ammo_cells;
  1397.  
  1398.     item.velocity_z = 300;
  1399.     item.velocity_x = -100 + (random() * 200);
  1400.     item.velocity_y = -100 + (random() * 200);
  1401.     
  1402.     item.flags = FL_ITEM;
  1403.     item.solid = SOLID_TRIGGER;
  1404.     item.movetype = MOVETYPE_TOSS;
  1405.     setmodel (item, "progs/backpack.mdl");
  1406.     setsize (item, '-16 -16 0', '16 16 56');
  1407.     item.touch = BackpackTouch;
  1408.     
  1409.     item.nextthink = time + 120;    // remove after 2 minutes
  1410.     item.think = SUB_Remove;
  1411. };
  1412.